package com.example.rebushu.controller;

import com.example.rebushu.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

@Controller
public class TestController {

    @RequestMapping("test1")
    public String test1(Model model){

        model.addAttribute("msg","hi");
        model.addAttribute("html","<h1>hello<h1>");
        model.addAttribute("username","jerry");
        model.addAttribute("msg1","hello");
        model.addAttribute("array",new String[] {"张安","李四","王二"});

        List<User> userList = new ArrayList<>();
        userList.add(new User(1L,"zhangsna","123456"));
        userList.add(new User(2L,"lisi","123456"));
        userList.add(new User(3L,"wanger","123456"));
        model.addAttribute("userList",userList);

        return "test/test1";
    }

    @RequestMapping("test2")
    public String test2(){

        return "test/test2";
    }

    @RequestMapping("test3")
    public String test3(){

        return "test/test3";
    }
    @RequestMapping("testform")
    public String testform(String username,String password){
        System.out.println(username + "::");
        return "test/test3";
    }
}
